#!/bin/bash

# Usage scenario:
#   user1: tm xx
#   user2: tm xx
#   user3: tm xx
# where "xx" can be any other session name.

session=$1
[[ $session ]] || session=pair

path=/tmp/tmm
[[ -d $path ]] || {
	mkdir $path
	chown .team $path
}

sock=$path/$session.sock

if tmux -S $path/$session.sock ls 2>/dev/null; then
	tmux -S $sock attach -t $session
else
	tmux -S $sock new-session -s $session "chgrp team $sock; zsh"
fi
